Skip to content

fix(indexer): UTF-8 encoding for git log on non-UTF-8 Windows locales#143

Open
rajkumarsakthivel wants to merge 6 commits into
mainfrom
fix/git-indexer-encoding-140
Open

fix(indexer): UTF-8 encoding for git log on non-UTF-8 Windows locales#143
rajkumarsakthivel wants to merge 6 commits into
mainfrom
fix/git-indexer-encoding-140

Conversation

@rajkumarsakthivel

Copy link
Copy Markdown
Member

Summary

Fixes #140. Git history indexing fails with UnicodeDecodeError on Windows machines using non-UTF-8 system locales (e.g. Korean cp949, Japanese Shift_JIS, Chinese GBK).

The two subprocess.run calls in index_commits used text=True without an explicit encoding=. Python decodes subprocess output using locale.getpreferredencoding(False), which on Windows returns the system ANSI codepage. Since git log output is always UTF-8, any non-ASCII commit message or author name that isn't valid in the system codepage raises UnicodeDecodeError.

Fix: pass encoding="utf-8", errors="replace" on both calls, matching git's actual output encoding. The errors="replace" fallback handles the rare case where git output contains non-UTF-8 bytes (e.g. legacy repos with Latin-1 commit messages) by substituting U+FFFD instead of crashing.

One-line change per call site, no new dependencies.

#140)

On Windows with non-UTF-8 system locales (e.g. Korean cp949), Python's
subprocess.run with text=True decodes using the system codepage. Git log
output is UTF-8 regardless of locale, so non-ASCII commit messages or
author names cause UnicodeDecodeError, aborting git history indexing.

Pass encoding="utf-8", errors="replace" on both subprocess.run calls in
index_commits to match git's actual output encoding.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Git history indexing fails with UnicodeDecodeError on non-UTF-8 Windows locales (e.g. Korean cp949)

1 participant